#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<vector<int>> levelOrder(Node* root) {
        vector<vector<int>> ret;
        if (root == nullptr)
            return ret;
        queue<Node*> q;
        q.push(root);
        while (q.size()) {
            int sz = q.size();
            vector<int> v;
            for (int i = 0; i < sz; i++) {
                Node* node = q.front();
                v.push_back(node->val);
                q.pop();
                for (auto e : node->children) {
                    if (e) {
                        q.push(e);
                    }
                }
            }
            ret.push_back(v);
        }

        return ret;
    }
};